<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        img{
            width: 100px;
            height: 100px;
        }

        #outer{
            /* border: 1px solid red; */
            text-align: center;
        }
    </style>
</head>
<body>
    
    <div id="outer">
        <div>
            <img id="img_d" src="../imgs/ql.jpeg" alt="">
        </div>
        <div>
            <a href="javascript:change(0)">1</a> 
            <a href="javascript:change(1)">2</a> 
            <a href="javascript:change(2)">3</a>
        </div>
    </div>

    <script>
        let arr = ["gdg.jpeg","ql.jpeg","yy.jpeg"];

        function change(n){
            //根据id获取img对象
            let img = document.getElementById("img_d");
            img.src='../imgs/'+arr[n];
        }
    </script>
</body>
</html>